# 引入smtplib库
import smtplib

# 引入email库
from email.mime.text import MIMEText
from email.header import Header

# 邮件发送方
sender = '2538760199@qq.com'

# 邮件接收方
receiver = '3306428634@qq.com'

# 邮件标题
subject = '图书馆管理系统'

# 邮件正文
#msg = MIMEText('这是Python邮件发送测试内容', 'plain', 'utf-8')



# SMTP服务和端口号
smtp_server = 'smtp.qq.com'
smtp_port = 25

# 发件人账号和密码
user = '2538760199@qq.com'
password = 'cuxargrjgphbecge'

def send_email(message,tosend):
    receiver = tosend
    msg = MIMEText(message, 'plain', 'utf-8')
    msg['From'] = Header(sender)
    msg['To'] = Header(receiver, 'utf-8')
    msg['Subject'] = Header(subject, 'utf-8')
    server = smtplib.SMTP(smtp_server, smtp_port)
    server.login(user, password)
    server.sendmail(sender, receiver, msg.as_string())
    server.quit()


if __name__ == '__main__':
    # 建立连接
    # server = smtplib.SMTP(smtp_server, smtp_port)
    # server.login(user, password)
    # server.sendmail(sender, receiver, msg.as_string())
    # server.quit()
    send_email("测试","3306428634@qq.com")
